<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>
        function Person2 (name,age){
            this.name=name;
            this.age=age;
            this.say=function(){
                console.log('说话呀');
            }
        }
        Person.prototype.study=function(){
            console.log('学习呀');
        }
        var p2=new Person('李四',20);
        console.log(p2);

        class Person{
            constructor(name,age){
                this.name=name;
                this.age=age;
                //实例方法
                this.say=function(){
                    console.log('说话');
                };
            }
            //原型方法
            study(){
                console.log('学习');
            }
        }
        var p=new Person('张三',22);
        console.log(p);
        p.study();
        p.say();
    </script>
</body>
</html>